package com.example.java8.utils;

import com.example.java8.common.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @Classname ListUtil
 * @Description TODO
 * @Date 2020/11/19 22:27
 * @Created by kevin
 */
public class ListUtil {

    public static void main( String[] args ) {

        List<Test> list1 = new ArrayList<>();
        List<Test> list2 = new ArrayList<>();

        list1.add(new Test("1",1));
        list1.add(new Test("2",2));
        list1.add(new Test("3",3));
        list1.add(new Test("4",4));
        list1.add(new Test("5",5));
        list1.add(new Test("6",6));


        /*list2.add(new Test("1",1));
        list2.add(new Test("2",1));
        list2.add(new Test("3",1));
        list2.add(new Test("4",1));
        list2.add(new Test("5",1));*/


        diff(list1,list2);
        System.out.println("==========================");
        diff(list2, list1);


    }

    public static List<Test> diff(List<Test> list1,List<Test> list2){
        List<Test> allList = new ArrayList<>(list1);
        allList.addAll(list2);
        List<Test> commList = new ArrayList<>(list1);
        commList.retainAll(list2);

        allList.removeAll(commList);

        allList.forEach(System.out::println);
        return allList;
    }
}
